package org.ant.gui.panes.ACtextpanel;

import java.awt.Dimension;

import javax.swing.JPanel;

public class LineNumberPanel extends JPanel{
	
	public static final int WIDTH = 35; 
	public static final int DEFAULT_SIZE = 500; 
	
	public LineNumberPanel(){
		this.setPreferredSize(new Dimension(WIDTH,100));
		this.setTotalNum(1);
	}
	
	public void setTotalNum(int n){
		int size = this.getComponentCount();
		
		while (n>size){
			this.add(new LineNumberLabel(size+1));
			size = this.getComponentCount();
		}
		
		size = this.getComponentCount();
		for (int i=0;i<size;i++){
			if (i<n){
				this.getComponent(i).setVisible(true);
			}else{
				while (i<size){
					this.getComponent(i).setVisible(false);
					i++;
				}
				break;
			}
		}
	}
	
	public void setError(int n,String error){
		((LineNumberLabel)this.getComponent(n-1)).setError(error);
	}
	
	public void clearError(int n){
		((LineNumberLabel)this.getComponent(n-1)).clearError();
	}
}
